package com.beaven.imclient.base;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * author: Beaven
 * time: 2017/5/22 10:01
 */

public abstract class BaseFragment extends Fragment {

  protected View rootView;

  @Override public void onAttach(Context context) {
    super.onAttach(context);
    initArgs(getArguments());
  }

  @Nullable @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
      @Nullable Bundle savedInstanceState) {
    rootView = inflater.inflate(getLayoutId(), container, false);
    initView(rootView);
    initData();
    return rootView;
  }

  protected void initArgs(Bundle arguments) {
  }

  protected abstract int getLayoutId();

  protected void initView(View rootView) {
  }

  protected void initData() {
  }
}
